<html>
<head><meta charset="utf-8"><title>how to run gdb on rustc? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/how.20to.20run.20gdb.20on.20rustc.3F.html">how to run gdb on rustc?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="217557726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/how%20to%20run%20gdb%20on%20rustc%3F/near/217557726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vikram Pal <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/how.20to.20run.20gdb.20on.20rustc.3F.html#217557726">(Nov 22 2020 at 16:06)</a>:</h4>
<p>Hi, I built the stage1 compiler using <code>./x.py build -i library/std</code>, and also created a corresponding toolchain <code>rustup toolchain link stage1 build/x86_64-unknown-linux-gnu/stage1</code>.However, when I try to debug it using <code>gdb --args rustc +stage1 -g -Aunused a.rs</code>, it cannot detect the source files. How can I run gdb on rustc?</p>



<a name="217567639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/how%20to%20run%20gdb%20on%20rustc%3F/near/217567639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/how.20to.20run.20gdb.20on.20rustc.3F.html#217567639">(Nov 22 2020 at 20:10)</a>:</h4>
<p>don't debug <code>rustc</code> provided via rustup. That's a shim file:</p>
<div class="codehilite"><pre><span></span><code>% which rustc
/Users/shep/.cargo/bin/rustc
</code></pre></div>



<a name="217567648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/how%20to%20run%20gdb%20on%20rustc%3F/near/217567648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/how.20to.20run.20gdb.20on.20rustc.3F.html#217567648">(Nov 22 2020 at 20:11)</a>:</h4>
<p>Instead, debug the target of that:</p>
<div class="codehilite"><pre><span></span><code>% rustup which rustc
/Users/shep/.rustup/toolchains/nightly-x86_64-apple-darwin/bin/rustc
</code></pre></div>



<a name="217567660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/how%20to%20run%20gdb%20on%20rustc%3F/near/217567660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/how.20to.20run.20gdb.20on.20rustc.3F.html#217567660">(Nov 22 2020 at 20:11)</a>:</h4>
<p>so maybe <code>gdb $(rustup which rustc)</code></p>



<a name="217568273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/how%20to%20run%20gdb%20on%20rustc%3F/near/217568273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vikram Pal <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/how.20to.20run.20gdb.20on.20rustc.3F.html#217568273">(Nov 22 2020 at 20:26)</a>:</h4>
<p>ok I am running gdb on the binary directly: <code>gdb --args build/x86_64-unknown-linux-gnu/stage1/bin/rustc -Aunused -g a.rs</code>. But it still says debugging symbols not found.</p>



<a name="217568276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/how%20to%20run%20gdb%20on%20rustc%3F/near/217568276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/how.20to.20run.20gdb.20on.20rustc.3F.html#217568276">(Nov 22 2020 at 20:26)</a>:</h4>
<p>you need <code>debug = true</code> in config.toml</p>



<a name="217568284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/how%20to%20run%20gdb%20on%20rustc%3F/near/217568284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/how.20to.20run.20gdb.20on.20rustc.3F.html#217568284">(Nov 22 2020 at 20:26)</a>:</h4>
<p><code>debuginfo = 2</code> if you want local variables, but I don't recommend that, it takes forever to build</p>



<a name="217569038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/how%20to%20run%20gdb%20on%20rustc%3F/near/217569038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vikram Pal <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/how.20to.20run.20gdb.20on.20rustc.3F.html#217569038">(Nov 22 2020 at 20:45)</a>:</h4>
<p>ok thanks!</p>



<a name="217671630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/how%20to%20run%20gdb%20on%20rustc%3F/near/217671630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/how.20to.20run.20gdb.20on.20rustc.3F.html#217671630">(Nov 23 2020 at 19:25)</a>:</h4>
<p>I though <a href="https://rustc-dev-guide.rust-lang.org/compiler-debugging.html">https://rustc-dev-guide.rust-lang.org/compiler-debugging.html</a> included instructions for debugging with gdb, but apparently I was wrong</p>



<a name="217673915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/how%20to%20run%20gdb%20on%20rustc%3F/near/217673915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/how.20to.20run.20gdb.20on.20rustc.3F.html#217673915">(Nov 23 2020 at 19:45)</a>:</h4>
<p><span class="user-mention" data-user-id="255061">@Léo Lanteri Thauvin</span> do you want to add some? :)</p>



<a name="217673945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/how%20to%20run%20gdb%20on%20rustc%3F/near/217673945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/how.20to.20run.20gdb.20on.20rustc.3F.html#217673945">(Nov 23 2020 at 19:45)</a>:</h4>
<p>I don’t think I’d be able to, sorry</p>



<a name="217673966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/how%20to%20run%20gdb%20on%20rustc%3F/near/217673966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/how.20to.20run.20gdb.20on.20rustc.3F.html#217673966">(Nov 23 2020 at 19:45)</a>:</h4>
<p>Don’t know enough on that topic</p>



<a name="217674916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/how%20to%20run%20gdb%20on%20rustc%3F/near/217674916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/how.20to.20run.20gdb.20on.20rustc.3F.html#217674916">(Nov 23 2020 at 19:53)</a>:</h4>
<p>Opened <a href="https://github.com/rust-lang/rustc-dev-guide/issues/965">https://github.com/rust-lang/rustc-dev-guide/issues/965</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>